; ModuleID = 'use_after_return.cc'
source_filename = "use_after_return.cc"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@ptr = local_unnamed_addr global { i32*, [56 x i8] } zeroinitializer, align 32, !dbg !0
@__asan_option_detect_stack_use_after_return = external global i32
@__asan_gen_ = private unnamed_addr constant [19 x i8] c"1 32 400 7 local:5\00", align 1
@__asan_gen_.1 = private constant [20 x i8] c"use_after_return.cc\00", align 1
@__asan_gen_.2 = private unnamed_addr constant [4 x i8] c"ptr\00", align 1
@__asan_gen_.3 = private unnamed_addr constant [20 x i8] c"use_after_return.cc\00", align 1
@__asan_gen_.4 = private unnamed_addr constant { [20 x i8]*, i32, i32 } { [20 x i8]* @__asan_gen_.3, i32 1, i32 6 }
@0 = internal global [1 x { i64, i64, i64, i64, i64, i64, i64, i64 }] [{ i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ i32*, [56 x i8] }* @ptr to i64), i64 8, i64 64, i64 ptrtoint ([4 x i8]* @__asan_gen_.2 to i64), i64 ptrtoint ([20 x i8]* @__asan_gen_.1 to i64), i64 0, i64 ptrtoint ({ [20 x i8]*, i32, i32 }* @__asan_gen_.4 to i64), i64 0 }]
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 1, void ()* @asan.module_ctor, i8* null }]
@llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 1, void ()* @asan.module_dtor, i8* null }]

; Function Attrs: noinline nounwind sanitize_address uwtable
define void @_Z30FunctionThatEscapesLocalObjectv() local_unnamed_addr #0 !dbg !14 {
  %asan_local_stack_base = alloca i64, !dbg !22
  %1 = load i32, i32* @__asan_option_detect_stack_use_after_return, !dbg !22
  %2 = icmp ne i32 %1, 0, !dbg !22
  br i1 %2, label %3, label %5

; <label>:3:                                      ; preds = %0
  %4 = call i64 @__asan_stack_malloc_3(i64 512), !dbg !22
  br label %5

; <label>:5:                                      ; preds = %0, %3
  %6 = phi i64 [ 0, %0 ], [ %4, %3 ], !dbg !22
  %7 = icmp eq i64 %6, 0, !dbg !22
  br i1 %7, label %8, label %10

; <label>:8:                                      ; preds = %5
  %MyAlloca = alloca i8, i64 512, align 32, !dbg !22
  %9 = ptrtoint i8* %MyAlloca to i64, !dbg !22
  br label %10

; <label>:10:                                     ; preds = %5, %8
  %11 = phi i64 [ %6, %5 ], [ %9, %8 ], !dbg !22
  store i64 %11, i64* %asan_local_stack_base, !dbg !22
  %12 = add i64 %11, 32, !dbg !22
  %13 = inttoptr i64 %12 to [100 x i32]*, !dbg !22
  %14 = inttoptr i64 %11 to i64*, !dbg !22
  store i64 1102416563, i64* %14, !dbg !22
  %15 = add i64 %11, 8, !dbg !22
  %16 = inttoptr i64 %15 to i64*, !dbg !22
  store i64 ptrtoint ([19 x i8]* @__asan_gen_ to i64), i64* %16, !dbg !22
  %17 = add i64 %11, 16, !dbg !22
  %18 = inttoptr i64 %17 to i64*, !dbg !22
  store i64 ptrtoint (void ()* @_Z30FunctionThatEscapesLocalObjectv to i64), i64* %18, !dbg !22
  %19 = lshr i64 %11, 3, !dbg !22
  %20 = add i64 %19, 2147450880, !dbg !22
  %21 = add i64 %20, 0, !dbg !22
  %22 = inttoptr i64 %21 to i64*, !dbg !22
  store i64 -506381209984437775, i64* %22, align 1, !dbg !22
  %23 = add i64 %20, 8, !dbg !22
  %24 = inttoptr i64 %23 to i64*, !dbg !22
  store i64 -506381209866536712, i64* %24, align 1, !dbg !22
  %25 = add i64 %20, 16, !dbg !22
  %26 = inttoptr i64 %25 to i64*, !dbg !22
  store i64 -506381209866536712, i64* %26, align 1, !dbg !22
  %27 = add i64 %20, 24, !dbg !22
  %28 = inttoptr i64 %27 to i64*, !dbg !22
  store i64 -506381209866536712, i64* %28, align 1, !dbg !22
  %29 = add i64 %20, 32, !dbg !22
  %30 = inttoptr i64 %29 to i64*, !dbg !22
  store i64 -506381209866536712, i64* %30, align 1, !dbg !22
  %31 = add i64 %20, 40, !dbg !22
  %32 = inttoptr i64 %31 to i64*, !dbg !22
  store i64 -506381209866536712, i64* %32, align 1, !dbg !22
  %33 = add i64 %20, 48, !dbg !22
  %34 = inttoptr i64 %33 to i64*, !dbg !22
  store i64 -868076554939729672, i64* %34, align 1, !dbg !22
  %35 = add i64 %20, 56, !dbg !22
  %36 = inttoptr i64 %35 to i64*, !dbg !22
  store i64 -868082074056920077, i64* %36, align 1, !dbg !22
  call void @llvm.dbg.declare(metadata i64* %asan_local_stack_base, metadata !18, metadata !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 32)), !dbg !23
  %37 = bitcast [100 x i32]* %13 to i8*, !dbg !24
  %38 = add i64 %20, 4, !dbg !24
  %39 = inttoptr i64 %38 to i64*, !dbg !24
  store i64 0, i64* %39, align 1, !dbg !24
  %40 = add i64 %20, 12, !dbg !24
  %41 = inttoptr i64 %40 to i64*, !dbg !24
  store i64 0, i64* %41, align 1, !dbg !24
  %42 = add i64 %20, 20, !dbg !24
  %43 = inttoptr i64 %42 to i64*, !dbg !24
  store i64 0, i64* %43, align 1, !dbg !24
  %44 = add i64 %20, 28, !dbg !24
  %45 = inttoptr i64 %44 to i64*, !dbg !24
  store i64 0, i64* %45, align 1, !dbg !24
  %46 = add i64 %20, 36, !dbg !24
  %47 = inttoptr i64 %46 to i64*, !dbg !24
  store i64 0, i64* %47, align 1, !dbg !24
  %48 = add i64 %20, 44, !dbg !24
  %49 = inttoptr i64 %48 to i64*, !dbg !24
  store i64 0, i64* %49, align 1, !dbg !24
  %50 = add i64 %20, 52, !dbg !24
  %51 = inttoptr i64 %50 to i16*, !dbg !24
  store i16 0, i16* %51, align 1, !dbg !24
  call void @llvm.lifetime.start.p0i8(i64 400, i8* nonnull %37) #4, !dbg !24
  %arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* %13, i64 0, i64 0, !dbg !25
  store i32* %arrayidx, i32** getelementptr inbounds ({ i32*, [56 x i8] }, { i32*, [56 x i8] }* @ptr, i32 0, i32 0), align 8, !dbg !26, !tbaa !27
  %52 = add i64 %20, 4, !dbg !31
  %53 = inttoptr i64 %52 to i64*, !dbg !31
  store i64 -506381209866536712, i64* %53, align 1, !dbg !31
  %54 = add i64 %20, 12, !dbg !31
  %55 = inttoptr i64 %54 to i64*, !dbg !31
  store i64 -506381209866536712, i64* %55, align 1, !dbg !31
  %56 = add i64 %20, 20, !dbg !31
  %57 = inttoptr i64 %56 to i64*, !dbg !31
  store i64 -506381209866536712, i64* %57, align 1, !dbg !31
  %58 = add i64 %20, 28, !dbg !31
  %59 = inttoptr i64 %58 to i64*, !dbg !31
  store i64 -506381209866536712, i64* %59, align 1, !dbg !31
  %60 = add i64 %20, 36, !dbg !31
  %61 = inttoptr i64 %60 to i64*, !dbg !31
  store i64 -506381209866536712, i64* %61, align 1, !dbg !31
  %62 = add i64 %20, 44, !dbg !31
  %63 = inttoptr i64 %62 to i64*, !dbg !31
  store i64 -506381209866536712, i64* %63, align 1, !dbg !31
  %64 = add i64 %20, 52, !dbg !31
  %65 = inttoptr i64 %64 to i16*, !dbg !31
  store i16 -1800, i16* %65, align 1, !dbg !31
  call void @llvm.lifetime.end.p0i8(i64 400, i8* nonnull %37) #4, !dbg !31
  store i64 1172321806, i64* %14, !dbg !31
  %66 = icmp ne i64 %6, 0, !dbg !31
  br i1 %66, label %67, label %73, !dbg !31

; <label>:67:                                     ; preds = %10
  %68 = add i64 %20, 0, !dbg !31
  call void @__asan_set_shadow_f5(i64 %68, i64 64), !dbg !31
  %69 = add i64 %6, 504, !dbg !31
  %70 = inttoptr i64 %69 to i64*, !dbg !31
  %71 = load i64, i64* %70, !dbg !31
  %72 = inttoptr i64 %71 to i8*, !dbg !31
  store i8 0, i8* %72, !dbg !31
  br label %75, !dbg !31

; <label>:73:                                     ; preds = %10
  %74 = add i64 %20, 0, !dbg !31
  call void @__asan_set_shadow_00(i64 %74, i64 64), !dbg !31
  br label %75, !dbg !31

; <label>:75:                                     ; preds = %73, %67
  ret void, !dbg !31
}

; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1

; Function Attrs: nounwind readnone speculatable
declare void @llvm.dbg.declare(metadata, metadata, metadata) #2

; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1

; Function Attrs: norecurse nounwind sanitize_address uwtable
define i32 @main(i32 %argc, i8** nocapture readnone %argv) local_unnamed_addr #3 !dbg !32 {
  call void @llvm.dbg.value(metadata i32 %argc, metadata !39, metadata !DIExpression()), !dbg !41
  call void @llvm.dbg.value(metadata i8** %argv, metadata !40, metadata !DIExpression()), !dbg !42
  tail call void @_Z30FunctionThatEscapesLocalObjectv(), !dbg !43
  %1 = load i32*, i32** getelementptr inbounds ({ i32*, [56 x i8] }, { i32*, [56 x i8] }* @ptr, i32 0, i32 0), align 8, !dbg !44, !tbaa !27
  %idxprom = sext i32 %argc to i64, !dbg !44
  %arrayidx = getelementptr inbounds i32, i32* %1, i64 %idxprom, !dbg !44
  %2 = ptrtoint i32* %arrayidx to i64, !dbg !44
  %3 = lshr i64 %2, 3, !dbg !44
  %4 = add i64 %3, 2147450880, !dbg !44
  %5 = inttoptr i64 %4 to i8*, !dbg !44
  %6 = load i8, i8* %5, !dbg !44
  %7 = icmp ne i8 %6, 0, !dbg !44
  br i1 %7, label %8, label %14, !dbg !44, !prof !45

; <label>:8:                                      ; preds = %0
  %9 = and i64 %2, 7, !dbg !44
  %10 = add i64 %9, 3, !dbg !44
  %11 = trunc i64 %10 to i8, !dbg !44
  %12 = icmp sge i8 %11, %6, !dbg !44
  br i1 %12, label %13, label %14, !dbg !44

; <label>:13:                                     ; preds = %8
  call void @__asan_report_load4(i64 %2), !dbg !44
  call void asm sideeffect "", ""()
  unreachable

; <label>:14:                                     ; preds = %8, %0
  %15 = load i32, i32* %arrayidx, align 4, !dbg !44, !tbaa !46
  ret i32 %15, !dbg !48
}

; Function Attrs: nounwind readnone speculatable
declare void @llvm.dbg.value(metadata, metadata, metadata) #2

declare void @__asan_report_load_n(i64, i64)

declare void @__asan_loadN(i64, i64)

declare void @__asan_report_load1(i64)

declare void @__asan_load1(i64)

declare void @__asan_report_load2(i64)

declare void @__asan_load2(i64)

declare void @__asan_report_load4(i64)

declare void @__asan_load4(i64)

declare void @__asan_report_load8(i64)

declare void @__asan_load8(i64)

declare void @__asan_report_load16(i64)

declare void @__asan_load16(i64)

declare void @__asan_report_store_n(i64, i64)

declare void @__asan_storeN(i64, i64)

declare void @__asan_report_store1(i64)

declare void @__asan_store1(i64)

declare void @__asan_report_store2(i64)

declare void @__asan_store2(i64)

declare void @__asan_report_store4(i64)

declare void @__asan_store4(i64)

declare void @__asan_report_store8(i64)

declare void @__asan_store8(i64)

declare void @__asan_report_store16(i64)

declare void @__asan_store16(i64)

declare void @__asan_report_exp_load_n(i64, i64, i32)

declare void @__asan_exp_loadN(i64, i64, i32)

declare void @__asan_report_exp_load1(i64, i32)

declare void @__asan_exp_load1(i64, i32)

declare void @__asan_report_exp_load2(i64, i32)

declare void @__asan_exp_load2(i64, i32)

declare void @__asan_report_exp_load4(i64, i32)

declare void @__asan_exp_load4(i64, i32)

declare void @__asan_report_exp_load8(i64, i32)

declare void @__asan_exp_load8(i64, i32)

declare void @__asan_report_exp_load16(i64, i32)

declare void @__asan_exp_load16(i64, i32)

declare void @__asan_report_exp_store_n(i64, i64, i32)

declare void @__asan_exp_storeN(i64, i64, i32)

declare void @__asan_report_exp_store1(i64, i32)

declare void @__asan_exp_store1(i64, i32)

declare void @__asan_report_exp_store2(i64, i32)

declare void @__asan_exp_store2(i64, i32)

declare void @__asan_report_exp_store4(i64, i32)

declare void @__asan_exp_store4(i64, i32)

declare void @__asan_report_exp_store8(i64, i32)

declare void @__asan_exp_store8(i64, i32)

declare void @__asan_report_exp_store16(i64, i32)

declare void @__asan_exp_store16(i64, i32)

declare i8* @__asan_memmove(i8*, i8*, i64)

declare i8* @__asan_memcpy(i8*, i8*, i64)

declare i8* @__asan_memset(i8*, i32, i64)

declare void @__asan_handle_no_return()

declare void @__sanitizer_ptr_cmp(i64, i64)

declare void @__sanitizer_ptr_sub(i64, i64)

declare i64 @__asan_stack_malloc_0(i64)

declare void @__asan_stack_free_0(i64, i64)

declare i64 @__asan_stack_malloc_1(i64)

declare void @__asan_stack_free_1(i64, i64)

declare i64 @__asan_stack_malloc_2(i64)

declare void @__asan_stack_free_2(i64, i64)

declare i64 @__asan_stack_malloc_3(i64)

declare void @__asan_stack_free_3(i64, i64)

declare i64 @__asan_stack_malloc_4(i64)

declare void @__asan_stack_free_4(i64, i64)

declare i64 @__asan_stack_malloc_5(i64)

declare void @__asan_stack_free_5(i64, i64)

declare i64 @__asan_stack_malloc_6(i64)

declare void @__asan_stack_free_6(i64, i64)

declare i64 @__asan_stack_malloc_7(i64)

declare void @__asan_stack_free_7(i64, i64)

declare i64 @__asan_stack_malloc_8(i64)

declare void @__asan_stack_free_8(i64, i64)

declare i64 @__asan_stack_malloc_9(i64)

declare void @__asan_stack_free_9(i64, i64)

declare i64 @__asan_stack_malloc_10(i64)

declare void @__asan_stack_free_10(i64, i64)

declare void @__asan_poison_stack_memory(i64, i64)

declare void @__asan_unpoison_stack_memory(i64, i64)

declare void @__asan_set_shadow_00(i64, i64)

declare void @__asan_set_shadow_f1(i64, i64)

declare void @__asan_set_shadow_f2(i64, i64)

declare void @__asan_set_shadow_f3(i64, i64)

declare void @__asan_set_shadow_f5(i64, i64)

declare void @__asan_set_shadow_f8(i64, i64)

declare void @__asan_alloca_poison(i64, i64)

declare void @__asan_allocas_unpoison(i64, i64)

declare void @__asan_before_dynamic_init(i64)

declare void @__asan_after_dynamic_init()

declare void @__asan_register_globals(i64, i64)

declare void @__asan_unregister_globals(i64, i64)

declare void @__asan_register_image_globals(i64)

declare void @__asan_unregister_image_globals(i64)

declare void @__asan_register_elf_globals(i64, i64, i64)

declare void @__asan_unregister_elf_globals(i64, i64, i64)

declare void @__asan_init()

define internal void @asan.module_ctor() {
  call void @__asan_init()
  call void @__asan_version_mismatch_check_v8()
  call void @__asan_register_globals(i64 ptrtoint ([1 x { i64, i64, i64, i64, i64, i64, i64, i64 }]* @0 to i64), i64 1)
  ret void
}

declare void @__asan_version_mismatch_check_v8()

define internal void @asan.module_dtor() {
  call void @__asan_unregister_globals(i64 ptrtoint ([1 x { i64, i64, i64, i64, i64, i64, i64, i64 }]* @0 to i64), i64 1)
  ret void
}

attributes #0 = { noinline nounwind sanitize_address uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { argmemonly nounwind }
attributes #2 = { nounwind readnone speculatable }
attributes #3 = { norecurse nounwind sanitize_address uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #4 = { nounwind }

!llvm.dbg.cu = !{!2}
!llvm.asan.globals = !{!8}
!llvm.module.flags = !{!10, !11, !12}
!llvm.ident = !{!13}

!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
!1 = distinct !DIGlobalVariable(name: "ptr", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
!3 = !DIFile(filename: "use_after_return.cc", directory: "/home/vagrant/proj/rust/mycode/rust_test/c")
!4 = !{}
!5 = !{!0}
!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)
!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!8 = !{i32** getelementptr inbounds ({ i32*, [56 x i8] }, { i32*, [56 x i8] }* @ptr, i32 0, i32 0), !9, !"ptr", i1 false, i1 false}
!9 = !{!"use_after_return.cc", i32 1, i32 6}
!10 = !{i32 2, !"Dwarf Version", i32 4}
!11 = !{i32 2, !"Debug Info Version", i32 3}
!12 = !{i32 1, !"wchar_size", i32 4}
!13 = !{!"clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)"}
!14 = distinct !DISubprogram(name: "FunctionThatEscapesLocalObject", linkageName: "_Z30FunctionThatEscapesLocalObjectv", scope: !3, file: !3, line: 4, type: !15, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: true, unit: !2, variables: !17)
!15 = !DISubroutineType(types: !16)
!16 = !{null}
!17 = !{!18}
!18 = !DILocalVariable(name: "local", scope: !14, file: !3, line: 5, type: !19)
!19 = !DICompositeType(tag: DW_TAG_array_type, baseType: !7, size: 3200, elements: !20)
!20 = !{!21}
!21 = !DISubrange(count: 100)
!22 = !DILocation(line: 4, scope: !14)
!23 = !DILocation(line: 5, column: 7, scope: !14)
!24 = !DILocation(line: 5, column: 3, scope: !14)
!25 = !DILocation(line: 6, column: 10, scope: !14)
!26 = !DILocation(line: 6, column: 7, scope: !14)
!27 = !{!28, !28, i64 0}
!28 = !{!"any pointer", !29, i64 0}
!29 = !{!"omnipotent char", !30, i64 0}
!30 = !{!"Simple C++ TBAA"}
!31 = !DILocation(line: 7, column: 1, scope: !14)
!32 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 9, type: !33, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: true, unit: !2, variables: !38)
!33 = !DISubroutineType(types: !34)
!34 = !{!7, !7, !35}
!35 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !36, size: 64)
!36 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !37, size: 64)
!37 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
!38 = !{!39, !40}
!39 = !DILocalVariable(name: "argc", arg: 1, scope: !32, file: !3, line: 9, type: !7)
!40 = !DILocalVariable(name: "argv", arg: 2, scope: !32, file: !3, line: 9, type: !35)
!41 = !DILocation(line: 9, column: 14, scope: !32)
!42 = !DILocation(line: 9, column: 27, scope: !32)
!43 = !DILocation(line: 10, column: 3, scope: !32)
!44 = !DILocation(line: 11, column: 10, scope: !32)
!45 = !{!"branch_weights", i32 1, i32 100000}
!46 = !{!47, !47, i64 0}
!47 = !{!"int", !29, i64 0}
!48 = !DILocation(line: 11, column: 3, scope: !32)
